<div data-hook="admin_payment_method_form_fields">

  <div data-hook="payment_method" class="row">

    <div class="col-12 col-md-6">
      <div class="card mb-3">
        <div class="card-header">
          <h5 class="mb-0"><%= Spree.t(:settings) %></h5>
        </div>
        <div class="card-body">
          <div class="form-group">
            <%= f.label :type, Spree.t(:provider) %>
            <%= collection_select(:payment_method, :type, @providers, :to_s, :name, {}, {id: 'gtwy-type', class: 'select2'}) %>
          </div>
          <hr class="my-4">
          <%= field_container :payment_method, :name, class: ['form-group'], 'data-hook' => 'name' do %>
            <%= label_tag :payment_method_name, Spree.t(:name) %>
            <%= text_field :payment_method, :name, class: 'form-control' %>
            <%= error_message_on :payment_method, :name %>
          <% end %>

          <%= field_container :payment_method, :description, class: ['form-group'], 'data-hook' => 'description' do %>
            <%= label_tag :payment_method_description, Spree.t(:description) %>
            <%= text_area :payment_method, :description, { cols: 60, rows: 6, class: 'form-control' } %>
          <% end %>

          <div data-hook="store" class="form-group">
            <%= label_tag :payment_method_stores, Spree.t(:stores) %>
            <%= collection_select(:payment_method, :store_ids, @stores, :id, :unique_name, {}, { multiple: true, class: 'select2' }) %>
          </div>

          <div data-hook="display" class="form-group">
            <%= label_tag :payment_method_display_on, Spree.t(:display) %>
            <%= select(:payment_method, :display_on, Spree::PaymentMethod::DISPLAY.collect { |display| [Spree.t(display), display.to_s] }, {}, {class: 'select2'}) %>
          </div>
          <div data-hook="auto_capture" class="form-group">
            <%= label_tag :payment_method_auto_capture, Spree.t(:auto_capture) %>
            <%= select(:payment_method, :auto_capture, [["#{Spree.t(:use_app_default)} (#{Spree::Config[:auto_capture]})", ''], [Spree.t(:say_yes), true], [Spree.t(:say_no), false]], {}, {class: 'select2'}) %>
          </div>

          <div data-hook="active" class="form-group">
            <strong><%= Spree.t(:active) %></strong>
            <div class="radio my-2 form-check">
              <%= radio_button :payment_method, :active, true, class: 'form-check-input' %>
              <%= label_tag :payment_method_active_true, Spree.t(:say_yes), class: 'form-check-label' %>
            </div>

            <div class="radio my-2 form-check">
              <%= radio_button :payment_method, :active, false, class: 'form-check-input' %>
              <%= label_tag :payment_method_active_false, Spree.t(:say_no), class: 'form-check-label' %>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="col-12 col-md-6">
      <div class="card mb-3">
        <div class="card-header">
          <h5 class="mb-0"><%= Spree.t(:payment_provider_settings) %></h5>
        </div>
        <div class="card-body">
          <div id="preference-settings" data-hook class="form-group">
            <% unless @object.new_record? %>
            <% if preference_fields(@object, f).empty? %>
              <%= Spree.t('no_payment_provider_settings_message') %>
            <% end %>
              <%= preference_fields(@object, f) %>

              <% if @object.respond_to?(:preferences) %>
                <div id="gateway-settings-warning" class="info warning"><%= Spree.t(:provider_settings_warning) %></div>
              <% end %>
            <% end %>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
